<!DOCTYPE html><html lang="zh-CN"><head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>day() | Moment.js &#x6587;&#x6863;</title>
  <link rel="stylesheet" href="static/css/style.css">
  <link rel="shortcut icon" href="http://momentjs.cn/static/img/moment-favicon.png">
  <link rel="stylesheet" href="static/css/atom-one-light.min.css">
</head>
<body class="is-moment">
  <div class="hero hero-oneline">
    <div class="hero-centered">
      <h1>day()</h1>
    </div>
  </div>
  <div id="api-section-__FILENAME__">
    <div id="content" class="clearfix">
  
      <div id="column1" data-id="__ID__" class="interior">
        <header>
          <!-- <h1>day()</h1> -->
          <div id="gtoc">
            <ul>
              <!-- <li>v</li> -->
              <li>
                <a href="index.html#/get-set/day/" name="toc">&#x8FD4;&#x56DE;&#x4E0A;&#x5C42;&#x6587;&#x6863;</a>
              </li>
              <li style="border: none;">
                <a href="javascript:window.open('https://github.com/momentjscn/moment-docs-cn/edit/master/moment/02-get-set/06-day.md');" rel="nofollow" target="_blank">&#x63D0;&#x4EA4;&#x4FEE;&#x6539;</a>
              </li>
              <!-- <li>
                <a href="/search__SEARCH_PARAM__" name="toc">搜索</a>
              </li> -->
            </ul>
          </div>
          <hr>
        </header>

        <div id="biz_item"></div>
  
        <div id="apicontent">
          <div id="content_left">
							<div class="docs-method-signature">
								<pre><code class="language-js">moment().day(Number|String);
moment().day(); // &#x6570;&#x5B57;
moment().days(Number|String);
moment().days(); // &#x6570;&#x5B57;
</code></pre>

							</div>
<p>&#x83B7;&#x53D6;&#x6216;&#x8BBE;&#x7F6E;&#x661F;&#x671F;&#x51E0;&#x3002;</p>
<p>&#x6B64;&#x65B9;&#x6CD5;&#x53EF;&#x7528;&#x4E8E;&#x8BBE;&#x7F6E;&#x661F;&#x671F;&#x51E0;&#xFF0C;&#x5176;&#x4E2D;&#x661F;&#x671F;&#x65E5;&#x4E3A; 0&#x3001;&#x661F;&#x671F;&#x516D;&#x4E3A; 6&#x3002;</p>
<p>&#x5982;&#x679C;&#x7ED9;&#x5B9A;&#x7684;&#x503C;&#x662F; 0 &#x5230; 6&#xFF0C;&#x5219;&#x7ED3;&#x679C;&#x7684;&#x65E5;&#x671F;&#x5C06;&#x4F1A;&#x5728;&#x5F53;&#x524D;&#xFF08;&#x661F;&#x671F;&#x65E5;&#x81F3;&#x661F;&#x671F;&#x516D;&#xFF09;&#x7684;&#x661F;&#x671F;&#x3002;</p>
<p>&#x5982;&#x679C;&#x8D85;&#x51FA;&#x8303;&#x56F4;&#xFF0C;&#x5219;&#x5B83;&#x5C06;&#x4F1A;&#x5192;&#x6CE1;&#x5230;&#x5176;&#x4ED6;&#x661F;&#x671F;&#x3002;</p>
<pre><code class="language-javascript">moment().day(-7); // &#x4E0A;&#x4E2A;&#x661F;&#x671F;&#x65E5; (0 - 7)
moment().day(0); // &#x8FD9;&#x4E2A;&#x661F;&#x671F;&#x65E5; (0)
moment().day(7); // &#x4E0B;&#x4E2A;&#x661F;&#x671F;&#x65E5; (0 + 7)
moment().day(10); // &#x4E0B;&#x4E2A;&#x661F;&#x671F;&#x4E09; (3 + 7)
moment().day(24); // &#x4ECE;&#x73B0;&#x5728;&#x8D77;&#x7B2C; 3 &#x4E2A;&#x661F;&#x671F;&#x4E09; (3 + 7 + 7 + 7)
</code></pre>
<p>&#x6CE8;&#x610F;&#xFF1A;<code>Moment#date</code> &#x662F;&#x6708;&#x4EFD;&#x7684;&#x65E5;&#x671F;&#xFF0C;&#x800C; <code>Moment#day</code> &#x662F;&#x661F;&#x671F;&#x51E0;&#x3002;</p>
<p>&#x4ECE; <strong>2.1.0</strong> &#x7248;&#x5F00;&#x59CB;&#xFF0C;&#x8FD8;&#x652F;&#x6301;&#x661F;&#x671F;&#x540D;&#x79F0;&#x3002;
&#x8FD9;&#x662F;&#x5728; moment &#x5F53;&#x524D;&#x7684;&#x8BED;&#x8A00;&#x73AF;&#x5883;&#x4E2D;&#x89E3;&#x6790;&#x7684;&#x3002;</p>
<pre><code class="language-javascript">moment().day(&quot;Sunday&quot;);
moment().day(&quot;Monday&quot;);
</code></pre>
					</div>
          <div id="content_right">
							<div class="docs-method-signature">
								<pre><code class="language-js">moment().day(Number|String);
moment().day(); // Number
moment().days(Number|String);
moment().days(); // Number
</code></pre>

							</div>
<p>Gets or sets the day of the week.</p>
<p>This method can be used to set the day of the week, with Sunday as 0 and Saturday as 6.</p>
<p>If the value given is from 0 to 6, the resulting date will be within the current (Sunday-to-Saturday) week.</p>
<p>If the range is exceeded, it will bubble up to other weeks.</p>
<pre><code class="language-javascript">moment().day(-7); // last Sunday (0 - 7)
moment().day(0); // this Sunday (0)
moment().day(7); // next Sunday (0 + 7)
moment().day(10); // next Wednesday (3 + 7)
moment().day(24); // 3 Wednesdays from now (3 + 7 + 7 + 7)
</code></pre>
<p><strong>Note:</strong> <code>Moment#date</code> is for the date of the month, and <code>Moment#day</code> is for the day of the week.</p>
<p>As of <strong>2.1.0</strong>, a day name is also supported. This is parsed in the moment&apos;s current locale.</p>
<pre><code class="language-javascript">moment().day(&quot;Sunday&quot;);
moment().day(&quot;Monday&quot;);
</code></pre>
					</div>
          <div></div>
        </div>
      </div>
    </div>
  </div>
  
  <script src="static/js/highlight.min.js"></script>
  <script src="static/js/javascript.min.js"></script>
  <script>hljs.initHighlightingOnLoad();</script>
  <script>var _hmt = _hmt || []; (function () { var hm = document.createElement("script"); hm.src = "//hm.baidu.com/hm.js?7a7f78c805fbacc7e075d34f153031aa"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(hm, s); })();</script>

  <style>
    .hero-centered {
      margin: 0;
          margin-left: 10px;
    }
#gtoc ul {
  list-style: none;
  margin-left: 0;
  line-height: 1.5rem;
  padding: 0;
}
#gtoc>ul>li {
  display: inline;
  border-right: 1px solid #000;
  margin-right: .4rem;
  padding-right: .4rem;
}
#gtoc>ul>li>a {
  color: #61b2a7;
}
#content_left {
  width: 49%;float: left;border-right: 1px solid #eee;    padding-right: 2%;
}
#content_right {
float: left;width: 48%;margin-left: 3%;
}
#column1 {
  padding: 0 2rem;
}
  </style>


</body></html>